/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.comac.ins.common.core.domain.R;
import com.comac.ins.common.core.validate.AddGroup;
import com.comac.ins.common.core.validate.EditGroup;
import com.comac.ins.common.excel.utils.ExcelUtil;
import com.comac.ins.common.idempotent.annotation.RepeatSubmit;
import com.comac.ins.common.log.annotation.Log;
import com.comac.ins.common.log.enums.BusinessType;
import com.comac.ins.common.mybatis.core.page.TableDataInfo;
import com.comac.ins.common.web.core.BaseController;
import com.comac.ins.isfd.domain.bo.IsfdLayupMetalCaseMetaBo;
import com.comac.ins.isfd.domain.bo.query.IsfdLayupMetalCaseMetaQueryBo;
import com.comac.ins.isfd.domain.vo.IsfdLayupMetalCaseMetaVo;
import com.comac.ins.isfd.service.IIsfdLayupMetalCaseMetaService;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 【铺层库金属壳元属性】
 *
 * @author Lion Li
 * @date 2024-08-02
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/isfd/layupMetalCaseMeta")
public class IsfdLayupMetalCaseMetaController extends BaseController {

    private final IIsfdLayupMetalCaseMetaService isfdLayupMetalCaseMetaService;

    /**
     * 查询【铺层库金属壳元属性】列表
     */
    @SaCheckPermission("isfd:layupMetalCaseMeta:list")
    @PostMapping("/list")
    public TableDataInfo<IsfdLayupMetalCaseMetaVo> list(@RequestBody IsfdLayupMetalCaseMetaQueryBo bo) {
        return isfdLayupMetalCaseMetaService.queryPageList(bo);
    }

    /**
     * 导出【铺层库金属壳元属性】列表
     */
    @SaCheckPermission("isfd:layupMetalCaseMeta:export")
    @Log(title = "【铺层库金属壳元属性】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(IsfdLayupMetalCaseMetaQueryBo bo, HttpServletResponse response) {
        List<IsfdLayupMetalCaseMetaVo> list = isfdLayupMetalCaseMetaService.queryList(bo);
        ExcelUtil.exportExcel(list, "【铺层库金属壳元属性】", IsfdLayupMetalCaseMetaVo.class, response);
    }

    /**
     * 获取【铺层库金属壳元属性】详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("isfd:layupMetalCaseMeta:query")
    @GetMapping("/{id}")
    public R<IsfdLayupMetalCaseMetaVo> getInfo(@NotNull(message = "主键不能为空")
                                               @PathVariable Long id) {
        return R.ok(isfdLayupMetalCaseMetaService.queryById(id));
    }

    /**
     * 新增【铺层库金属壳元属性】
     */
    @SaCheckPermission("isfd:layupMetalCaseMeta:add")
    @Log(title = "【铺层库金属壳元属性】", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody IsfdLayupMetalCaseMetaBo bo) {
        return toAjax(isfdLayupMetalCaseMetaService.insertByBo(bo));
    }

    /**
     * 修改【铺层库金属壳元属性】
     */
    @SaCheckPermission("isfd:layupMetalCaseMeta:edit")
    @Log(title = "【铺层库金属壳元属性】", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody IsfdLayupMetalCaseMetaBo bo) {
        return toAjax(isfdLayupMetalCaseMetaService.updateByBo(bo));
    }

    /**
     * 删除【铺层库金属壳元属性】
     *
     * @param ids 主键串
     */
    @SaCheckPermission("isfd:layupMetalCaseMeta:remove")
    @Log(title = "【铺层库金属壳元属性】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(isfdLayupMetalCaseMetaService.deleteWithValidByIds(List.of(ids), true));
    }
}
